﻿@{
    ViewBag.Title = "费用类别";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js"></script>
<script language="javascript" type="text/javascript">
    $(function () {
        //InitChargingUnitCombobox();
    });

    function addLKCostTypes() {
        InitChargingUnitCombobox();
        $('#UnitName').val($("#ChargingUnit").combobox('getText'))
        $('#fm').form('clear');
        $('#dlg').dialog('open');
        url = '/BasicManage/AddLKCostTypes';
    }

    function editLKCostTypes() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要编辑的信息?');
            return;
        }
        $('#dlg').dialog('open').dialog('setTitle', '编辑');
        InitChargingUnitCombobox();
        $('#UnitName').val($("#ChargingUnit").combobox('getText'))
        $.messager.progress({
            title: '请稍后',
            msg: '数据加载中...',
        });
        window.setTimeout(function () {
            $('#fm').form('load', row);
            $.messager.progress('close');
        }, 1000);

        url = "/BasicManage/EditLKCostTypes";
    }

    function delLKCostTypes() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/BasicManage/DeleteLKCostTypes", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    $('#dg').datagrid('load');
                }
            });
        });
    }

    function saveLKCostTypes() {
        $('#hidUnitName').val($("#ChargingUnit").combobox('getText'))
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                Helper.Show(json.Msg);
                if (json.Success) {
                    $('#fm').form('clear');
                    $('#dlg').dialog('close');
                    $('#dg').datagrid('reload');
                }
            }
        });
    }

</script>
<table id="dg" class="easyui-datagrid" style="width:100%; height: 600px;"
       url="/BasicManage/GetLKCostTypes" toolbar="#tb" title="费用类别" rownumbers="true" pagination="true"
       pagelist="[15]" fitcolumns="true" singleselect="true">
    <thead>
        <tr>
            <th field="CostTypeName" align="right" width="10%">
                费用类别名称
            </th>
            <th field="UnitPrice" align="right" width="10%">
                单价
            </th>
            <th field="Unit" align="right" width="10%">
                单位
            </th>
            <th field="UnitName" align="right" width="10%">
                单位名称
            </th>
            <th field="Remark" align="right" width="10%">
                描述
            </th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addLKCostTypes()">新建</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editLKCostTypes()">编辑</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delLKCostTypes()">删除</a>
    </div>
</div>


<div id="dlg" class="easyui-dialog" title="新增" data-options="iconCls:'icon-save'"
     closed="true" style="width: 450px; height: 300px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <form id="fm" method="post" novalidate>
        <input type="hidden" name="Id" />
        <input type="hidden" id="hidIsSysTem" name="IsSysTem" />
        <input type="hidden" id="hidUnitName" name="UnitName" />
        <div class="fitem">
            <label>
                类别名称:
            </label>
            <input name="CostTypeName" id="CostTypeName" data-options="required: true" class="easyui-textbox" style="width: 173px; height: 30px;" />
        </div>
        <div class="fitem">
            <label>
                单价:
            </label>
            <input name="UnitPrice" id="UnitPrice" class="easyui-numberbox" data-options="required: true,precision:'2'" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                单位:
            </label>
            <select class="easyui-combogrid" style="width: 173px; height: 30px;" name="Unit" id="ChargingUnit"></select>
        </div>
        <div class="fitem">
            <label>
                描述:
            </label>
            <input name="Remark" id="Remark" class="easyui-textbox" style="width: 173px; height: 30px;"/>
        </div>
        @*<div class="fitem">
            <label>
                是否系统:
            </label>
            <input class="easyui-switchbutton" id="sbIsSysTem" data-options="onText:'是',offText:'否'" >
        </div>*@
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveLKCostTypes()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>







